<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>流量查询</title>
    <link href="css/swiper.min.css" rel="stylesheet"/>
    <link href="css/public.css" rel="stylesheet"/>
    <link href="css/main.css" rel="stylesheet"/>
    <link href="css/style.css" rel="stylesheet"/>
    <script src="http://www.jq22.com/jquery/jquery-1.9.1.js"></script>
    <script src="js/mobile-util.js"></script>
    <script src="js/layer/layer.js"></script>
	<script src="js/public.js"></script>
	<script src="js/laydate.js"></script>
	<script src="js/datatime.js"></script>
	<style>

		.traffic{
			padding: .5rem;
		}
		.trafficlist{
			padding: 1rem 0;
			border-bottom: 1px solid #F0EFF5;
			font-size: .6rem;
			color: #383737;
		}
		.traffictime{
			color: #EB4149;
			font-size: .6rem;
			margin-left: 1rem;
			position: relative;
		}
		.recordmain div{
			font-size: .6rem;
		}
	</style>

	<script>
		/*获取url参数*/
		function getUrlParam(name) {
			var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
			var r = window.location.search.substr(1).match(reg);  //匹配目标参数
			if (r != null) return unescape(r[2]); return null; //返回参数值
		}

		/*获取url参数end*/
	</script>

</head>
<body>

<div class="markbox">
	<img src="img/loading1.gif" />
</div>

<header class="mui-bar mui-bar-nav indexheader flex">
    <div class="headerlogo" onclick="back()">
        <i class="iconfont backbtn">&#xe602;</i>
    </div>

    <div class="headertitle">
        <p>流量查询</p>
    </div>

    <div class="headerright timeright hide">
        <p class="timepbox iconfont">&#xe6d9;</p>

    </div>

</header>


<main class="recordmain">

	<div class="traffic">
		<div class="trafficlist flex">
			<div class="flex-1">
				套餐到期时间 <span class="traffictime"></span>
			</div>


		</div>

		<div class="trafficlist flex">
			<div class="flex-1">
				当月已用流量
			</div>

			<div class="flex-1 te-ri" id="consumptionmonth">

			</div>
		</div>

		<div class="trafficlist flex">
			<div class="flex-1">
				当前套餐已用流量
			</div>

			<div class="flex-1 te-ri" id="consumption">

			</div>
		</div>

		<div class="trafficlist flex">
			<div class="flex-1">
				套餐名称
			</div>

			<div class="flex-1 te-ri" id="package">

			</div>
		</div>

	</div>


</main>

</body>


<script>

	$(function(){
		var device_sn=getUrlParam("device_sn");
		var url1="http://wifi.qianlh.com";
		//console.log(device_sn);


		$('.markbox').show();
		 setTimeout(function(){
			$('.markbox').hide();

		}, 2000);

		$.ajax({
			type: 'get',
			url: url1 +"/Mobile/Userapi/get_to_device?device_id=" + device_sn,
			success:function(data){

				var data1=JSON.parse(data);

				var result=data1.result;
				if(result == 70003){
					alert('设备不存在');

					window.location.href="equipment.html";

				}else if(result == 70006){
					alert('设备未激活');
					window.location.href="equipment.html";
				}else if(result == 0){
					var package_name=data1.package_name;
					var cur_expire_date=data1.cur_expire_date/1000;
					var cur_month_used_flow=data1.cur_month_used_flow+"MB";
					var cur_used_flow=data1.cur_used_flow+"MB";
					$('.traffictime').html($.myTime.UnixToDate(cur_expire_date));
					$('#package').html(package_name);
					$('#consumptionmonth').html(cur_month_used_flow);
					$('#consumption').html(cur_used_flow);


					//console.log($.myTime.UnixToDate(cur_expire_date));

				}

				console.log(data1);

			},error:function(data){
				console.log(data);
			}
		})
	})


</script>



</html>
